<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>

    //创建对象方式一
    person = new Object();
    person.firstName = "Koizumi";
    person.lastName = "Sinya";
    person.age = 26;
    person.eyeColor = "black";
    document.write(person.firstName + person.lastName + person.age + person.eyeColor);

    //创建对象方式二
    student = {firstName: "Mike", lastName: "Sparrow", age: 45, eyeColor: "blue"};

    //函数的方式创建对象
    function person(firstname, lastname, age, eyecolor) {
        this.firstName = firstname;
        this.lastName = lastname;
        this.age = age;
        this.eyeColor = eyecolor;
    }

    var Jack = new person("Jack", "Shelly", 18, "green");


    //函数创建对象 并对对象设置内部方法
    function student(name, age) {
        this.name = name;
        this.age = age;

        function setExamScore(score) {
            this.score = score;
        }
    }

    var carl = new student("Carl", 17);
    carl.setExamScore(98);


</script>
</body>
</html>